﻿/**
* @author languid
*/
$(function () {
    var level = function (root) {
        var nav = $(root);
        nav.each(function () {
            var root = $(this)
            root.children("li").each(function () {
                var $this = $(this), ul = $this.children('ul'), li = ul.children('li');
                if (ul.size() && li.size()) {
                    $this.hover(function () {
                        $this.addClass('current')
                        ul.show()
                    }, function () {
                        $this.removeClass('current')
                        ul.hide()
                    });
                }
            });
        })
    }

    new level(function () {
        return $('#nav').find('ul').each(function () {
            new level($(this))
        }).end()
    } ())
});